import tkinter as tk
from tkinter import *
from tkinter.filedialog import (askopenfilename)

class AppUI:
    def __init__(self):
        window = tk.Tk()
        window.geometry('600x600')
        window.title("铁头辅助器")
        window.resizable(False, False)

        # 定义第一个容器
        frame_left = tk.LabelFrame(window, text="登录", labelanchor="nw")
        frame_left.place(relx=0.05, rely=0.02, relwidth=0.6, relheight=0.2)
        path = tk.StringVar()
        tk.Entry(frame_left, textvariable=path).place(relx=0.05, rely=0.05, relwidth=0.6, relheight=0.3)
        tk.Button(frame_left, text="选择启动路径", command=selectPath).place(relx=0.7, rely=0.05, relwidth=0.25,
                                                                       relheight=0.3)

        tk.Button(frame_left, text="启动游戏").place(relx=0.05, rely=0.55, relwidth=0.2, relheight=0.3)
        tk.Button(frame_left, text="启动辅助").place(relx=0.4, rely=0.55, relwidth=0.2, relheight=0.3)
        tk.Button(frame_left, text="暂停辅助").place(relx=0.75, rely=0.55, relwidth=0.2, relheight=0.3)

        # 定义第二个容器
        frame_right = tk.LabelFrame(window, text="功能", labelanchor="nw")
        frame_right.place(relx=0.7, rely=0.02, relwidth=0.25, relheight=0.95)

        var = tk.StringVar()

        r1 = tk.Radiobutton(frame_right, text='幻境确认', variable=var, value='A')
        r1.place(relx=0.2, rely=0.05, relwidth=0.6, relheight=0.05)
        r2 = tk.Radiobutton(frame_right, text='自动门派', variable=var, value='B')
        r2.place(relx=0.2, rely=0.15, relwidth=0.6, relheight=0.05)
        r3 = tk.Radiobutton(frame_right, text='狗弟采花', variable=var, value='C')
        r3.place(relx=0.2, rely=0.25, relwidth=0.6, relheight=0.05)
        r1.deselect()



        tk.Button(frame_right, text="选择功能").place(relx=0.2, rely=0.9, relwidth=0.6, relheight=0.05)
        # 第三容器
        frame_left2 = tk.LabelFrame(window, text="运行日志", labelanchor="nw")
        frame_left2.place(relx=0.05, rely=0.22, relwidth=0.6, relheight=0.75)

        lf1_3 = tk.Frame(frame_left2)
        lf1_3.pack(side=TOP, fill=Y, padx=5, pady=5)

        self.msglist = Text(lf1_3, width=45, height=31)
        self.msglist.pack(side=LEFT, fill=Y)
        self.msglist.tag_config('important', foreground='blue')
        self.msglist.tag_config('warning', foreground='red')
        scroll = Scrollbar(lf1_3)
        self.msglist.configure(yscrollcommand=scroll.set)
        scroll.pack(side=RIGHT, fill=Y)

        window.mainloop()


def selectPath():
    # 选择文件path_接收文件地址
    path_ = tk.filedialog.askopenfilename()

if __name__ == '__main__':
    AppUI()


    # window = tk.Tk()
    # # 第4步，在图形界面上创建一个标签用以显示内容并放置
    # tk.Label(window, text='on the window', bg='red', font=('Arial', 16)).pack()  # 和前面部件分开创建和放置不同，其实可以创建和放置一步完成
    #
    # # 第5步，创建一个主frame，长在主window窗口上
    # frame = tk.Frame(window)
    # frame.pack()
    #
    # # 第6步，创建第二层框架frame，长在主框架frame上面
    # frame_l = tk.Frame(frame)  # 第二层frame，左frame，长在主frame上
    # frame_r = tk.Frame(frame)  # 第二层frame，右frame，长在主frame上
    # frame_l.pack(side='left')
    # frame_r.pack(side='right')
    #
    # # 第7步，创建三组标签，为第二层frame上面的内容，分为左区域和右区域，用不同颜色标识
    # tk.Label(frame_l, text='on the frame_l1', bg='green').pack()
    # tk.Label(frame_l, text='on the frame_l2', bg='green').pack()
    # tk.Label(frame_l, text='on the frame_l3', bg='green').pack()
    # tk.Label(frame_r, text='on the frame_r1', bg='yellow').pack()
    # tk.Label(frame_r, text='on the frame_r2', bg='yellow').pack()
    # tk.Label(frame_r, text='on the frame_r3', bg='yellow').pack()
    #
    # # 第8步，主窗口循环显示
    # window.mainloop()